package zhklappoint.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import zhklappoint.dao.ActivityDao;
import zhklappoint.dao.PayStatusDao;
import zhklappoint.entity.Activity;
import zhklappoint.entity.PayStatus;
import zhklappoint.enums.ENUM_ISDELETE;
import zhklappoint.service.InsertIntoOrderInfoService;
import zhklappoint.util.PageUtils;

@Service
public class InsertIntoOrderInfoServiceImpl implements InsertIntoOrderInfoService{

	@Autowired
	private PayStatusDao psd;
	
	@Override
	public PayStatus savePayStatus(PayStatus payStatus) {
		return psd.save(payStatus);
	}

	@Override
	public Page<PayStatus> getPayStatusList(PayStatus payStatus, Integer page, Integer size) {
		payStatus.setIsdelete(ENUM_ISDELETE.NOT_DELETED.value);
        Pageable pageable= PageUtils.toPageable(page, size, Sort.Direction.DESC, "createdate");
        ExampleMatcher matcher=ExampleMatcher.matching()
                .withMatcher("isdelete", ExampleMatcher.GenericPropertyMatchers.exact())
                .withMatcher("companyId", ExampleMatcher.GenericPropertyMatchers.exact())
                .withIgnorePaths("createdate","updatedate");// 忽略字段，即不管忽略名字是什么值都不加入查询条件
        Example<PayStatus> example = Example.of(payStatus, matcher);
        return psd.findAll(example, pageable);
	}
}
